@inherits PartialViewMacroPage
@using Umbraco.Cms.Web
@using Umbraco.Cms.Web.Macros
@using Umbraco.Framework
@{
 var home = DynamicModel.AncestorsOrSelf.Last();
 string menuItem = "<li {2}><a href=\"{0}\">{1}</a></li>";
 string activeClass = String.Empty; 
}
<nav>
  <ul>
    @if(DynamicModel.Id == home.Id)
    {
     <li id="first" class="active"><a href="@home.Url">@home.Name</a></li>
    }
   else
    {
     <li id="first"><a href="@home.Url">@home.Name</a></li>
    }
   
   @foreach(var node in home.Children)
     {      
       if(node.showInTopNav == "True")
       { 
         if(DynamicModel.AncestorsOrSelf.Any("id == @0", node.Id))
              {
               activeClass = "class=\"active\"";
              }
             else
              {
               activeClass = string.Empty;
              }
          @Html.Raw(string.Format(menuItem , node.Url, node.Name, activeClass));        
       }
     }   		   
  </ul>
</nav>
